{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5><font style="color:green">{$customer.nickname}</font> 的下级列表</h5>
            <h5 style="float:right">
                <a href="javascript:history.go(-1)" style="color:green">返回 ></a></h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">
                    <div class="table-responsive">
                        <div class="col-sm-12">
                            <form method="post" action="{:url('childCustomerList', ['customer_id'=>$customer.id])}" class="form-inline">
                                <input placeholder="微信号" class="form-control" name="nickname-like" value="{$nickname|default=''}" type="text">

                                <button class="btn btn-success btn-sm" type="submit" style="margin-bottom:0;margin-left:4px"><i class="fa fa-filter"></i> 筛选</button>
                                <a class="btn btn-primary btn-sm"  style="margin-bottom:0" href="{:url('childCustomerList', ['customer_id'=>$customer.id])}"><i class="fa fa-filter"></i> 重置</a>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th>微信号</th>
                                <th>总收益</th>
                                <th>推广位</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list-content">
                            {foreach $list as $vo}
                                <tr class="long-td">
                                    <td>{$vo["nickname"]}</td>
                                    <td>{$vo.history_profit}</td>
                                    <td>{$vo["yx_pid"]}</td>
                                    <td>
                                        <a href="{:url('edit', ['id'=>$vo.id])}" class="btn btn-primary btn-xs">
                                            <i class="fa fa-info-circle"></i> 详情</a>&nbsp;&nbsp;
                                        <a href="javascript:;" onclick="relieveParent('{$vo.id}')" class="btn btn-danger btn-xs">
                                            <i class="fa fa-close"></i> 解除关系</a>
                                    </td>
                                </tr>
                            {/foreach}
                        </tbody>
                    </table>
                    {$list->render()|raw}
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}
<script type="text/javascript">

function relieveParent(customerId) {
    layer.confirm('确定要解除关系吗？', {icon: 3}, function(index){
        $.ajax({
            url: "{:url('relieveParentCustomer')}",
            type: "post",
            data: {
                customer_id: customerId
            },
            dataType: "json",
            beforeSend:function() {
                // 显示loading
                index2 = layer.load(0, {
                    shade: [0.3,'#fff']
                });
            },
            success:function(data) {

                if (data['code'] != 1) {

                    layer.msg(data.msg,{icon:2,time:1000,shade: 0.1,}, function(index){
                        layer.close(index)
                    });
                    return false;
                }

                layer.msg(data.msg, {icon: 1,time:1000,shade:0.1}, function(index) {
                    window.location.reload()
                });
            },
            complete:function() {
                // 隐藏loading
                layer.close(index2);
            }
        });
    });
}

</script>

</body>
</html>